import React, { useEffect, useState } from 'react';
import DescriptionsCondition from '@/components/DescriptionsCondition';
import DrawerCondition from '@/components/DrawerCondition';
import PopImgShow from '@/components/PopImgShow';
import TableDataBlock from '@/components/TableDataBlock';
import { connect } from 'umi';
import { Space, Tag } from 'antd'
import { workType_status, commissionType_info } from '@/common/contact';
const commissionItemSnap = (props) => {
  const { dispatch, list = [], onClose } = props;
  const getColumns = [
    {
      title: '订单编号',
      dataIndex: 'orderSn',
    },
    {
      title: '分佣金额修改记录',
      dataIndex: 'commissionFeeRemark',
    },
    {
      title: '用户名',
      dataIndex: 'username',
    },
    {
      title: '头像',
      dataIndex: 'profile',
      render: (e) => {
        return <PopImgShow url={e}></PopImgShow>
      }
    },
    {
      title: '手机',
      dataIndex: 'mobile',
    },
    {
      title: '商品名称',
      dataIndex: 'orderDesc',
      render: (e) => {
        const goods = e ? JSON.parse(e) : {}
        const { goodsCover, goodsName } = goods
        return <Space>
          <PopImgShow url={goodsCover}></PopImgShow>
          <div>{goodsName}</div>
        </Space>
      }
    },
    {
      title: '阶段',
      dataIndex: 'stageInfo',
      render: (e = {}) => {
        const { stageName } = e
        return stageName || '--'
      }
    },
    {
      title: '阶段业绩比例(%)',
      dataIndex: 'stagePerformancePercentage',

    },
    {
      title: '阶段业绩',
      dataIndex: 'stagePerformance',
    },
    {
      title: '阶段佣金比例(%)',
      dataIndex: 'stageCommissionPercentage',

    },
    {
      title: '阶段佣金',
      dataIndex: 'stageCommission',

    },
    {
      title: '阶段实际佣金',
      dataIndex: 'stageRealCommission',
    },
    {
      title: '阶段扣除佣金',
      dataIndex: 'stageDeductCommission',
    },
    {
      title: '阶段扣除佣金比例(%)',
      dataIndex: 'stageDeductCommissionPercentage',
    },
    {
      title: '订单扣除佣金',
      dataIndex: 'orderDeductCommission',
    },
    {
      title: '订单实际支付金额',
      dataIndex: 'orderPayFee',
    },


  ];
  const expandedRowRender = (e) => {
    const { adminCommissionList = [] } = e
    const columnsItems = [
      {
        title: '订单号',
        dataIndex: 'orderSn',
      },
      {
        title: '姓名',
        dataIndex: 'username',
      },
      {
        title: '头像',
        dataIndex: 'profile',
        render: (e) => {
          return <PopImgShow url={e}></PopImgShow>
        }
      },
      {
        title: '负责类型',
        dataIndex: 'workType',
        render: (e) => {
          return workType_status[e]
        }
      },
      {
        title: '是否确认',
        dataIndex: 'confirmFlag',
        render: (e) => {
          return { 0: '否', 1: '是' }[e]
        }
      },

      {
        title: '阶段',
        dataIndex: 'stageInfo',
        render: (e = {}) => {
          const { stageName } = e
          return stageName || '--'
        }
      },
      {
        title: '增减',
        dataIndex: 'addType',
      },
      {
        title: '结算类型',
        dataIndex: 'commissionSettleMonth',
      },
      {
        title: '级别名称',
        dataIndex: 'levelName',
      },
      {
        title: '业绩',
        dataIndex: 'performance',
      },
      {
        title: '业绩比例(%)',
        dataIndex: 'performancePercentage',
      },
      {
        title: '阶段业绩比例(%)',
        dataIndex: 'stagePerformancePercentage',
      },
      {
        title: '阶段业绩',
        dataIndex: 'stagePerformance',
      },
      {
        title: '佣金',
        dataIndex: 'commission',
      },
      {
        title: '实际佣金',
        dataIndex: 'realCommission',
      }, {
        title: '佣金比例(%)',
        dataIndex: 'commissionPercentage',
      }, {
        title: '阶段佣金比例(%)',
        dataIndex: 'stageCommissionPercentage',
      }, {
        title: '阶段佣金',
        dataIndex: 'stageCommission',
      }, {
        title: '阶段实际佣金',
        dataIndex: 'stageRealCommission',
      },
      {
        title: '扣除佣金',
        dataIndex: 'deductCommission',
      },
      {
        title: '阶段扣除佣金',
        dataIndex: 'stageDeductCommission',
      },
      {
        title: '阶段扣除佣金比例(%)',
        dataIndex: 'stageDeductCommissionPercentage',
      },
      {
        title: '订单扣除佣金',
        dataIndex: 'orderDeductCommission',
      },
      {
        title: '订单实际支付金额',
        dataIndex: 'orderPayFee',
      },
    ]
    if (adminCommissionList.length > 0) {
      return <TableDataBlock columns={columnsItems} list={adminCommissionList} pagination={false} />;
    }
    return null

  };
  return (
    <TableDataBlock
      expandable={{
        expandedRowRender,
        defaultExpandAllRows: true,
        expandRowByClick: true
      }}
      // searchItems={searchItems}
      columns={getColumns}
      list={list}
      rowKey={(record) => `${record.id}`}
    ></TableDataBlock>
  );
};
export default commissionItemSnap
